package com.ruoyi.web.work.service.impl;

import java.math.BigDecimal;
import java.util.List;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.web.common.Result;
import com.ruoyi.web.work.domain.dbo.KeyBasicDO;
import com.ruoyi.web.work.domain.dbo.KeyProcessDO;
import com.ruoyi.web.work.domain.dto.ProcessInputDTO;
import com.ruoyi.web.work.mapper.KeyProcessMapper;
import org.springframework.stereotype.Service;
import com.ruoyi.web.work.mapper.KeyBasicMapper;
import com.ruoyi.web.work.domain.KeyBasic;
import com.ruoyi.web.work.service.IKeyBasicService;

import javax.annotation.Resource;

/**
 * 流转作业卡Service业务层处理
 *
 * @author gsx
 * @date 2021-02-28
 */
@Service
public class KeyBasicServiceImpl extends ServiceImpl<KeyBasicMapper, KeyBasicDO> implements IKeyBasicService
{
    @Resource
    private KeyBasicMapper keyBasicMapper;

    /**
     * 查询流转作业卡
     *
     * @param id 流转作业卡ID
     * @return 流转作业卡
     */
    @Override
    public KeyBasic selectKeyBasicById(Integer id)
    {
        return keyBasicMapper.selectKeyBasicById(id);
    }

    /**
     * 查询流转作业卡列表
     *
     * @param keyBasic 流转作业卡
     * @return 流转作业卡
     */
    @Override
    public List<KeyBasic> selectKeyBasicList(KeyBasic keyBasic)
    {
        return keyBasicMapper.selectKeyBasicList(keyBasic);
    }

    /**
     * 新增流转作业卡
     *
     * @param keyBasic 流转作业卡
     * @return 结果
     */
    @Override
    public int insertKeyBasic(KeyBasic keyBasic)
    {
        keyBasic.setCreateTime(DateUtils.getNowDate());
//        //合格率
//        if(ObjectUtil.isNotEmpty(keyBasic.getNum())&&ObjectUtil.isNotEmpty(keyBasic.getWasteNum())){
//            long l = (keyBasic.getNum() - keyBasic.getWasteNum()) / keyBasic.getNum();
//            BigDecimal fpy = new BigDecimal(l);
//            keyBasic.setFpy(fpy);
//        }

        return keyBasicMapper.insertKeyBasic(keyBasic);
    }

    /**
     * 修改流转作业卡
     *
     * @param keyBasic 流转作业卡
     * @return 结果
     */
    @Override
    public int updateKeyBasic(KeyBasic keyBasic)
    {
        keyBasic.setUpdateTime(DateUtils.getNowDate());
        return keyBasicMapper.updateKeyBasic(keyBasic);
    }

    /**
     * 批量删除流转作业卡
     *
     * @param ids 需要删除的流转作业卡ID
     * @return 结果
     */
    @Override
    public int deleteKeyBasicByIds(Integer[] ids)
    {
        return keyBasicMapper.deleteKeyBasicByIds(ids);
    }

    /**
     * 删除流转作业卡信息
     *
     * @param id 流转作业卡ID
     * @return 结果
     */
    @Override
    public int deleteKeyBasicById(Integer id)
    {
        return keyBasicMapper.deleteKeyBasicById(id);
    }

}
